package com.hontech.bv.ui.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bv.R

class PipeLineDropCupView (ctx: Context, attrs: AttributeSet) : FrameLayout(ctx, attrs) {

    private val btnDrop1: Button
    private val btnDrop2: Button
    private val btnHide: Button

    init {
        val view = LayoutInflater.from(ctx).inflate(R.layout.view_pipe_line_drop_cup, this)

        btnHide = view.findViewById<Button>(R.id.id_pipe_line_drop_cup_btn_hide)
        btnDrop1 = view.findViewById(R.id.id_pipe_line_drop_cup_btn1)
        btnDrop2 = view.findViewById(R.id.id_pipe_line_drop_cup_btn2)

        btnHide.setOnClickListener {
            if (btnDrop1.visibility == VISIBLE) {
                hide()
            } else {
                show()
            }
        }
    }

    private fun show() {
        btnHide.text = "隐藏"
        btnDrop2.visibility = VISIBLE
        btnDrop1.visibility = VISIBLE
    }

    private fun hide() {
        btnHide.text = "显示"
        btnDrop2.visibility = GONE
        btnDrop1.visibility = GONE
    }

}